import { IPSModelSortable } from '../ipsmodel-sortable';
import { IPSSysSFPlugin } from '../res/ipssys-sfplugin';
import { IPSSubSysServiceAPIDE } from './ipssub-sys-service-apide';
import { IPSSubSysServiceAPIDEField } from './ipssub-sys-service-apidefield';
import { IPSSubSysServiceAPIDEMethod } from './ipssub-sys-service-apidemethod';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSubSysServiceAPIDEImpl extends PSModelObjectImpl implements IPSSubSysServiceAPIDE, IPSModelSortable {
  get aPIMode(): 1 | 0 | 9 {
    return this.M.aPIMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dETag(): string {
    return this.M.dETag;
  }

  get dETag2(): string {
    return this.M.dETag2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get methodScriptCode(): string {
    return this.M.methodScriptCode;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected pssubsysserviceapidefields: IPSSubSysServiceAPIDEField[] | null = null;

  getPSSubSysServiceAPIDEFields(): IPSSubSysServiceAPIDEField[] | null {
    if (this.pssubsysserviceapidefields == null) {
      this.pssubsysserviceapidefields = this.fillChildListModel(this.M.getPSSubSysServiceAPIDEFields, 'service.IPSSubSysServiceAPIDEField') as IPSSubSysServiceAPIDEField[];
    }
    return this.pssubsysserviceapidefields;
  }

  get psSubSysServiceAPIDEFields(): IPSSubSysServiceAPIDEField[] | null {
    return this.getPSSubSysServiceAPIDEFields();
  }

  findPSSubSysServiceAPIDEField(objKey: any): IPSSubSysServiceAPIDEField | null {
    return this.getPSModel5('service.IPSSubSysServiceAPIDEField', this.getPSSubSysServiceAPIDEFields(), objKey) as IPSSubSysServiceAPIDEField;
  }

  protected pssubsysserviceapidemethods: IPSSubSysServiceAPIDEMethod[] | null = null;

  getPSSubSysServiceAPIDEMethods(): IPSSubSysServiceAPIDEMethod[] | null {
    if (this.pssubsysserviceapidemethods == null) {
      this.pssubsysserviceapidemethods = this.fillChildListModel(this.M.getPSSubSysServiceAPIDEMethods, 'service.IPSSubSysServiceAPIDEMethod') as IPSSubSysServiceAPIDEMethod[];
    }
    return this.pssubsysserviceapidemethods;
  }

  get psSubSysServiceAPIDEMethods(): IPSSubSysServiceAPIDEMethod[] | null {
    return this.getPSSubSysServiceAPIDEMethods();
  }

  findPSSubSysServiceAPIDEMethod(objKey: any): IPSSubSysServiceAPIDEMethod | null {
    return this.getPSModel5('service.IPSSubSysServiceAPIDEMethod', this.getPSSubSysServiceAPIDEMethods(), objKey) as IPSSubSysServiceAPIDEMethod;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端扩展插件');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get major(): boolean {
    return this.M.major != null ? this.M.major : false;
  }

  get nested(): boolean {
    return this.M.nested != null ? this.M.nested : false;
  }

  get cls(): string {
    return 'PSSubSysServiceAPIDEImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'service.IPSSubSysServiceAPIDE') return true;
    return super.instanceof(cls);
  }
}
